/*
	Copyright (c) 2010 <copyright holders>
	This source code is licensed under The MIT License,
	see the file LICENSE for details.
	*/

#ifndef FRAMEHANDLER_HPP
#define FRAMEHANDLER_HPP

#include <OGRE/OgreFrameListener.h>
#include <OGRE/OgrePrerequisites.h>
#include <OIS/OISKeyboard.h>
#include <OIS/OISMouse.h>
#include <vector>

#include "ForwardDecls.hpp"

namespace spelprog2 {

class FrameHandler : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener {
    Game & game_;
    OIS::InputManager * inputMan;
    OIS::Mouse * mouse;
    OIS::Keyboard * keyboard;
    float mouseX_, mouseY_; //because OIS has so poor mouse sensitivity
    bool quit_;

    float getNormalizedMouseX() const;
    float getNormalizedMouseY() const;
public:
    FrameHandler(Game & game);
    ~FrameHandler();

    void setQuitFlag() { quit_ = true; } //because calling Ogre::shutdown() causes bad things to happen

    virtual bool frameStarted(const Ogre::FrameEvent & ev);
    virtual bool frameRenderingQueued(const Ogre::FrameEvent & ev);

    virtual bool keyPressed(const OIS::KeyEvent & ev);
	virtual bool keyReleased(const OIS::KeyEvent & ev);

    virtual bool mouseMoved(const OIS::MouseEvent & ev);
    virtual bool mousePressed(const OIS::MouseEvent & ev, OIS::MouseButtonID id);
    virtual bool mouseReleased(const OIS::MouseEvent & ev, OIS::MouseButtonID id);
};

}; //namespace spelprog2

#endif //FRAMEHANDLER_HPP
